<template>
  <div class="header-container">
    <div class="header-content">
      <div class="left-content">
        <div class="energy-usage-overview" @click="handlerChoiceMenuItemClick('home')">
          <span :class="{ color: route.name === 'home' }">首页</span>
          <div class="row-line" v-if="route.name === 'home'"></div>
        </div>
        <div class="energy-usage-overview" @click="handlerChoiceMenuItemClick('energyuse')">
          <span :class="{ color: route.name === 'energyuse' }">用能概况</span>
          <div class="row-line" v-if="route.name === 'energyuse'"></div>
        </div>
        <div class="real-time-monitor" @click="handlerChoiceMenuItemClick('realtimemonitor')">
          <span :class="{ color: route.name === 'realtimemonitor' }">实时监测</span>
          <div class="row-line" v-if="route.name === 'realtimemonitor'"></div>
        </div>
        <div class="maximum-demand" @click="handlerChoiceMenuItemClick('maximum')">
          <span :class="{ color: route.name === 'maximum' }">最大需量</span>
          <div class="row-line" v-if="route.name === 'maximum'"></div>
        </div>
      </div>
      <div class="right-content">
        <div class="time">10:21:06</div>
        <div class="date">2023/09/01</div>
        <div class="wel-msg">欢迎您！</div>
        <el-dropdown size="large">
          <div class="avator"></div>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="logoutClick('login')">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import router from '@/router'

import { useRouter, useRoute } from 'vue-router'
import { useStore } from 'vuex'
const store = useStore()
const route = useRoute()

const handlerChoiceMenuItemClick = (name) => {
  //每次跳转菜单 都要重新调用一次客户列表刷新
  store.dispatch('customerUpdateForMy')
  router.push({ name })
}
const logoutClick = (name) => {
  store.dispatch('login/usersLogout')
  router.push({ name })
}
</script>

<style lang="scss" scoped>
.color {
  color: #3dfdfb;
}
.header-container {
  width: 100%;
  height: 97px;
  background-image: url('@/assets/images/header-bg.png');
  background-size: 100% 100%;
  padding: 26px 28px;
  display: flex;
  justify-content: end;
  .header-content {
    display: flex;
    align-items: center;
    .left-content {
      display: flex;
      align-items: center;
      margin-right: 159px;
      font-size: 16px;
      font-family: AlimamaShuHeiTi-Bold, AlimamaShuHeiTi;
      font-weight: bold;
      color: #fcf8f8;
      line-height: 22px;
      text-shadow: 0px 3px 14px #0e1617;
      .row-line {
        width: 12px;
        height: 2px;
        background: #3dfdfb;
        border-radius: 2px;
        margin-top: 6px;
      }
      .energy-usage-overview {
        margin-right: 110px;
      }
      .real-time-monitor {
        margin-right: 107px;
      }
      .energy-usage-overview,
      .real-time-monitor,
      .maximum-demand {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        height: 30px;
        &:hover {
          cursor: pointer;
        }
      }
    }
    .right-content {
      display: flex;
      @mixin textbase() {
        text-shadow: 0px 3px 14px #0e1617;
        display: flex;
        align-items: center;
      }
      .time {
        font-size: 16px;
        font-family: QTypeSquare-Medium, QTypeSquare;
        font-weight: 500;
        color: #33f7eb;
        @include textbase;
        margin-right: 20px;
      }
      .date {
        font-size: 12px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #30f5e7;
        @include textbase;
        margin-right: 20px;
      }
      .wel-msg {
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        @include textbase;
        color: #3afcf6;
      }
      .avator {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background-color: rgb(0, 255, 191);
      }
    }
  }
}
</style>